{include file="public/header"}
<body>
<script src="/static/global/drag/Sortable.min.js"></script>
<script src="/static/global/drag/vuedraggable.umd.min.js"></script>
<div id="app" v-cloak>
    <div class="ht-main">
        <div class="ht-search">
            <el-form :inline="true" size="small">
                <el-form-item label="炉台">
                    <el-select placeholder="请选择" v-model="searchKey.category_id">
                        <el-option
                                v-for="item in arctypeList"
                                :key="item.id"
                                :label="item.title"
                                :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="时间">
                    <el-date-picker
                            v-model="searchKey.create_time"
                            type="daterange" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                            range-separator="至"
                            :picker-options="pickerOptions"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-button type="success" icon="el-icon-search" @click="search">搜索</el-button>
                    <el-button type="" icon="el-icon-refresh" @click="reset">重置</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="ht-tool">
            <div class="ht-tool-left">
               <el-button type="success" size="mini" icon="el-icon-plus" @click="doAdd">添加</el-button>
               <el-button type="primary" :disabled="tableSelect.length !== 1" size="mini" icon="el-icon-edit"
                          @click="edit(tableSelect[0])">编辑
               </el-button>
                <el-button type="danger" :disabled="!tableSelect.length" size="mini" icon="el-icon-delete"
                           @click="batchDel('/admin/production/del')">删除
                </el-button>
            </div>
            <div class="ht-tool-right">
            </div>
        </div>
        <div class="ht-main-body">
            <el-table :data="tableData" border header-row-class-name="ht-table-header"
                      ref="dataTable" @selection-change="handleSelectChange" row-key="title"
            >
                <el-table-column
                        align="center"
                        type="selection"
                        width="39">
                </el-table-column>
                <el-table-column align="center" prop="tianche" label="天车日产量(吨)"></el-table-column>
                <el-table-column align="center" prop="dianhao" label="电耗"></el-table-column>
                <el-table-column align="center" prop="dundiaohao" label="吨电耗(kw/h)"></el-table-column>
                <el-table-column align="center" prop="dunkuanghao" label="吨矿耗(吨)"></el-table-column>
                <el-table-column align="center" prop="gonglv" label="功率因数"></el-table-column>
    
                <el-table-column align="center" prop="yaci_a" label="二次电流 (KA)" v-if="1==2">
                    <el-table-column align="center" prop="dianliu_a" label="A"></el-table-column>
                    <el-table-column align="center" prop="dianliu_b" label="B"></el-table-column>
                    <el-table-column align="center" prop="dianliu_c" label="C"></el-table-column>
                </el-table-column>
                
                <el-table-column align="center" prop="yaci_a" label="二次电压 (V)" v-if="1==2">
                    <el-table-column align="center" prop="dianya_a" label="A"></el-table-column>
                    <el-table-column align="center" prop="dianya_b" label="B"></el-table-column>
                    <el-table-column align="center" prop="dianya_c" label="C"></el-table-column>
                </el-table-column>
                
                <el-table-column align="center" prop="yaci_a" label="电流/电压" v-if="1==2">
                    <el-table-column align="center" prop="diandao_a" label="A"></el-table-column>
                    <el-table-column align="center" prop="diandao_b" label="B"></el-table-column>
                    <el-table-column align="center" prop="diandao_c" label="C"></el-table-column>
                </el-table-column>
                
                <el-table-column align="center" prop="yaci_a" label="电极糊消耗 ( kg )">
                    <el-table-column align="center" prop="jihu_a" label="A"></el-table-column>
                    <el-table-column align="center" prop="jihu_b" label="B"></el-table-column>
                    <el-table-column align="center" prop="jihu_c" label="C"></el-table-column>
                </el-table-column>
    
                <el-table-column align="center" prop="yaci_a" label="电极压放量(mm)">
                    <el-table-column align="center" prop="jiya_a" label="A"></el-table-column>
                    <el-table-column align="center" prop="jiya_b" label="B"></el-table-column>
                    <el-table-column align="center" prop="jiya_c" label="C"></el-table-column>
                </el-table-column>
    
                <el-table-column align="center" prop="yaci_a" label="电极压次教">
                    <el-table-column align="center" prop="yaci_a" label="A相"></el-table-column>
                    <el-table-column align="center" prop="yaci_b" label="B相"></el-table-column>
                    <el-table-column align="center" prop="yaci_c" label="C相"></el-table-column>
                </el-table-column>
    
                <el-table-column align="center" prop="kongleng" label="空冷前温度"></el-table-column>
                <el-table-column align="center" prop="huiliang" label="吨耗卸灰量"></el-table-column>
                <el-table-column align="center" prop="tingdian" label="停电时间"></el-table-column>
    
                <el-table-column align="center" prop="category.title" label="所属炉台"></el-table-column>
    
                <el-table-column
                        align="center" fixed="right"
                        label="操作"
                        width="180">
                    <template slot-scope="scope">
                        <el-button @click="edit(scope.row)" size="mini" type="primary" icon="el-icon-edit"></el-button>
                        <el-button @click="del(scope.row)" size="mini" type="danger" icon="el-icon-delete"></el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="ht-main-page">
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="page"
                        :page-sizes="[1,10, 200, 300, 400]"
                        :page-size="limit"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total">
                </el-pagination>
            </div>
            <el-drawer
                    :visible.sync="is_edit"
                    size="90%"
                    :with-header="false"
                    custom-class="ht-drawer-bg"
                    :append-to-body="true"
                    :destroy-on-close="true"
            >
                <div class="ht-drawer-main">
                    <el-page-header @back="goBack" title="Esc返回" :content="content"></el-page-header>
                    <div class="ht-form">
                        <el-form :model="editData" label-width="120px" size="small">
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="天车日产量">
                                        <el-input placeholder="天车日产量" v-model="editData.tianche">
                                            <template slot="append">吨</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电耗">
                                        <el-input placeholder="电耗" v-model="editData.dianhao">
                                            <template slot="append">万度</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="吨电耗">
                                        <el-input placeholder="吨电耗"  v-model="editData.dundiaohao"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8" v-if="1===2">
                                    <el-form-item label="矿耗">
                                        <el-input placeholder="矿耗" v-model="editData.kuanghao">
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="入炉矿石">
                                        <el-input placeholder="入炉矿石" v-model="editData.kuangshi">
                                            <template slot="append">吨</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
            
                                <el-col :span="8">
                                    <el-form-item label="有功功率">
                                        <el-input placeholder="有功功率" v-model="editData.yougonglv"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="功率因素">
                                        <el-input placeholder="功率因素" v-model="editData.gonglv"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="吨矿耗">
                                        <el-input placeholder="吨矿耗"  v-model="editData.dunkuanghao"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="大焦">
                                        <el-input placeholder="大焦"  v-model="editData.dajiao">
                                            <template slot="append">吨</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="小焦">
                                        <el-input placeholder="小焦" v-model="editData.xiaojiao">
                                            <template slot="append">吨</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="二次电流A">
                                        <el-input placeholder="二次电流A"  v-model="editData.dianliu_a">
                                            <template slot="append">KA</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="二次电流B">
                                        <el-input placeholder="二次电流B" v-model="editData.dianliu_b">
                                            <template slot="append">KA</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="二次电流C">
                                        <el-input placeholder="二次电流C"  v-model="editData.dianliu_c">
                                            <template slot="append">KA</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="二次电压A">
                                        <el-input placeholder="二次电压A" v-model="editData.dianya_a"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="二次电压B">
                                        <el-input placeholder="二次电压B"  v-model="editData.dianya_b"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="二次电压C">
                                        <el-input placeholder="二次电压C"  v-model="editData.dianya_c"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="电流/电压A">
                                        <el-input placeholder="电流/电压A"  v-model="editData.diandao_a"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电流/电压B">
                                        <el-input placeholder="电流/电压B"  v-model="editData.diandao_b"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电流/电压C">
                                        <el-input placeholder="电流/电压C"  v-model="editData.diandao_c"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row v-if="1===2">
                                <el-col :span="8">
                                    <el-form-item label="电极压次数A">
                                        <el-input placeholder="电极压次数A"  v-model="editData.yaci_a"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电极压次数B">
                                        <el-input placeholder="电极压次数B"  v-model="editData.yaci_b"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电极压次数C">
                                        <el-input placeholder="电极压次数C"  v-model="editData.yaci_c"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="电极压放量A">
                                        <el-input placeholder="电极压放量A"  v-model="editData.jiya_a">
                                            <template slot="append">mm</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电极压放量B">
                                        <el-input placeholder="电极压放量B"  v-model="editData.jiya_b">
                                            <template slot="append">mm</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电极压放量C">
                                        <el-input placeholder="电极压放量C"  v-model="editData.jiya_c">
                                            <template slot="append">mm</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="电极糊消耗A">
                                        <el-input placeholder="电极糊消耗A"  v-model="editData.jihu_a"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电极糊消耗B">
                                        <el-input placeholder="电极糊消耗B"  v-model="editData.jihu_b"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电极糊消耗C">
                                        <el-input placeholder="电极糊消耗C"  v-model="editData.jihu_c"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="焦耗">
                                        <el-input placeholder="焦耗"  v-model="editData.da_jiaohao"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8" v-if="1===2">
                                    <el-form-item label="小焦焦耗">
                                        <el-input placeholder="小焦焦耗"  v-model="editData.xiao_jiaohao"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="电极糊总量">
                                        <el-input placeholder="电极糊总量"  v-model="editData.jihu_z"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="空冷前温度">
                                        <el-input placeholder="空冷前温度" v-model="editData.kongleng">
                                            <template slot="append">℃</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="卸灰总量">
                                        <el-input placeholder="卸灰总量"  v-model="editData.xiehui">
                                            <template slot="append">吨</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="吨耗卸灰量">
                                        <el-input placeholder="吨耗卸灰量"  v-model="editData.huiliang">
                                            <template slot="append">KG</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
        
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="停电时间">
                                        <el-input placeholder="停电时间" v-model="editData.tingdian"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="所属炉台">
                                        <el-select placeholder="请选择" @change="setJiHu" v-model="editData.category_id">
                                            <el-option
                                                    v-for="item in arctypeList"
                                                    :key="item.id"
                                                    :label="item.title"
                                                    :value="item.id">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-form-item>
                                <el-button @click="goBack">取消</el-button>
                                <el-button type="primary" @click="onSubmit">提交</el-button>
                            </el-form-item>
                        </el-form>
                    </div>
                </div>
            </el-drawer>
        </div>

    </div>
</div>
{include file="public/common"}
<script>
    let vs ;
    let del_url = "{:url('standard/del')}";
    let add_url = "{:url('standard/add')}";
    let index_url = "{:url('standard/index')}";
    var vm = new Vue({
        el: "#app",
        data: function () {
            return {
                showDialog: false,
                arctypeList: [],
                activeTab: 'first',
                tableData: [],
                is_edit: false,
                editData: {},
                editDataTemp: {},
                content: '编辑',
                total: 0,
                page: 1,
                limit: 10,
                userList: [],
                sourceList: [],
                regionList: [],
                phpList:[],
                fileManage:false,
                enterpriseList:[],
                pickerOptions: {
                    shortcuts: [{
                        text: '最近一周',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近一个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近三个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                imageList:[]
                
            }
        },
        created: function () {
            vs = this;
            this.getData()
            vs.getCategory()
        },
        methods: {
            setXieHui() {
                if (vs.editData.xiehui) {
                    vs.$set(vs.editData, 'huiliang',(vs.editData.xiehui / vs.editData.tianche * 1000).toFixed(2))
                }
            },
            setDunHao() {
                console.log(vs.editData.tianche,vs.editData.dianhao)
                if (vs.editData.tianche && vs.editData.dianhao) {
                    vs.$set(vs.editData, 'dundiaohao',(vs.editData.dianhao *10000 / vs.editData.tianche).toFixed(2))
                }
                if (vs.editData.tianche && vs.editData.kuanghao) {
                    vs.$set(vs.editData, 'dunkuanghao',(vs.editData.kuanghao / vs.editData.tianche).toFixed(2))
                }
            },
            setDianDao() {
                if (vs.editData.dianliu_a && vs.editData.dianya_a) {
                    vs.$set(vs.editData, 'diandao_a', vs.editData.dianliu_a * 1000 / vs.editData.dianya_a)
                }
                if (vs.editData.dianliu_b && vs.editData.dianya_b) {
                    vs.$set(vs.editData, 'diandao_b', vs.editData.dianliu_b * 1000 / vs.editData.dianya_b)
                }
                if (vs.editData.dianliu_c && vs.editData.dianya_c) {
                    vs.$set(vs.editData, 'diandao_c', vs.editData.dianliu_c * 1000 / vs.editData.dianya_c)
                }
            },
            setJiHu() {
                let xishu = 2.6;
                if ([15,16,17].indexOf(vs.editData.category_id) !== -1) {
                    xishu = 3.0;
                }
                if (vs.editData.jiya_a) {
                    vs.$set(vs.editData, 'jihu_a', vs.editData.jiya_a * xishu)
                }
                if (vs.editData.jiya_b) {
                    vs.$set(vs.editData, 'jihu_b', vs.editData.jiya_b * xishu)
                }
                if (vs.editData.jiya_c) {
                    vs.$set(vs.editData, 'jihu_c', vs.editData.jiya_c * xishu)
                }
            },
            getCategory() {
                Api.request("{:url('Category/all')}").then(res=>{
                    vs.arctypeList = res.data
                })
            },
            onSubmit() {
                var that = this
                $.post(add_url, that.editData, function (res) {
                    if (res.code == 1) {
                        that.showSuccessMsgCall(function () {
                            that.is_edit = false;
                            that.showDialog = false;
                            that.editData = {};
                            that.getData()
                        })
                    } else {
                        that.showErrorMsg(res.msg)
                    }
                })
            },
            getData: function () {
                var that = this
                that.searchType = {
                    content: 'like',
                    create_time:'between time'
                };
                $.post(index_url, {
                    limit: that.limit,
                    page: that.page,
                    search_key: that.searchKey,
                    search_type: that.searchType
                }, function (res) {
                    if (res.code == 1) {
                        that.tableData = res.data.data
                        that.total = res.data.total
                    } else {
                        that.showErrorMsg(res.msg)
                    }
                })
            },
            doAdd: function () {
                this.is_edit = true
                this.content = '添加'
                this.editData = {region_id:0}
            },
            edit: function (data) {
                this.is_edit = true
                this.content = '编辑'
                this.editData = data

                console.log(data)
            },
            goBack: function () {
                this.is_edit = false
            },
            del: function (data) {
                var that = this
                that.$confirm('确定删除么?', '提示', {
                    type: 'warning',
                    lockScroll: false
                }).then(() => {
                    $.post(del_url, {id: data.id}, function (res) {
                        if (res.code == 1) {
                            that.showSuccessMsgCall(function () {
                                that.getData()
                            })
                        } else {
                            that.showErrorMsg(res.msg)
                        }
                    })
                })
            },
            handleSizeChange: function (e) {
                this.limit = e
            },
            handleCurrentChange: function (e) {
                this.page = e
            }
        },
        watch: {
            page(v) {
                this.getData()
            },
            limit() {
                this.getData()
            }
        }
    })
</script>
</body>
</html>
